﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSites.Data.MenuMgmt;
using TSites.Common.Enums;
using TSites.Utility;

namespace TSites.MenuMgmt
{
    public class MenuMgmtService:LoggerBase , IMenuMgmtService
    {
        IMenuDao MenuDao { get; set; }

        protected override Type LogPrefix
        {
            get { return typeof(MenuMgmtService); }
        }

        public Common.Enums.RET_CODE Save(Core.Domain.MenuMgmt.Menu menu)
        {
            RET_CODE rt;
            try
            {
                if (menu.ID == 0)
                    MenuDao.Insert(menu);
                else
                    MenuDao.Update(menu);
                rt = RET_CODE.SUCCESS;
            }
            catch (Exception ex)
            {
                Error(ex.Message, ex);
                rt = RET_CODE.DB_ERROR;
            }
            
            return rt;
        }

        public IList<Core.Domain.MenuMgmt.Menu> GetList()
        {
            return MenuDao.GetListMenu();
        }
    }
}
